{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="{:url('Admin/pwd')}" lay-filter="component-form-group">
                <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
                    <div class="layui-tab-content">
                        <div class="layui-form-item">
                            <label class="layui-form-label">管理员账户</label>
                            <div class="layui-input-inline">
                                <input type="text" value="{$info['name']}" name="name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">管理员密码</label>
                            <div class="layui-input-inline">
                                <input type="password" value="" name="password" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认密码</label>
                            <div class="layui-input-inline">
                                <input type="password" value="" name="r_password" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux"></div>
                        </div>

                        <!--<div class="layui-tab-item">内容2</div>-->
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formSub">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>


    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate', 'upload'], function () {
        var $ = layui.$
            , form = layui.form
            ,upload = layui.upload
            , table = layui.table;


        form.on('submit(formSub)', function(data){
            console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
            console.log(data.form.action) //被执行提交的form对象，一般在存在form标签时才会返回
            if(data.field.password!=data.field.r_password){
                layer.alert('密码不一致');
                return false;
            }
            var param = data.field;
            $.ajax({
                type: 'POST'
                ,url: data.form.action
                ,data: param
                ,dataType: 'json'
                ,success:function(res){
                    if (res.code == 0){
                        layer.alert("修改成功");
                    } else{
                        layer.alert(res.msg);
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#bus_img_btn'
            , url: "{:url('common/upload_img')}"
            , data: {name:'ad'}
            , accept: 'images'
            , acceptMime: 'image/*,image/gif'
            , done: function (res) {
                $('#bus_img_btn').attr('src',res.data.img);
                $('#thumb').val(res.data.img);
            }
            , error: function () {
            }
        });
    });
</script>
</body>
</html>
{/block}
